/**
* Vista asociada al contenido 
* del tab de la funcionalidad CAMARA(Contenedor)
* en el aplicativo.
*/
Ext.define('entgpv11.view.ImageCamera', {
    extend: 'Ext.navigation.View',
    alias: 'widget.imagecamera',
    /*
    'Ext.device.Connection',
    'Ext.device.Notification',
    'Ext.device.Orientation'
    */
    requires: [
        'Ext.device.Camera',
        'entgpv11.view.imagecamera.ImageDetails',
        'Ext.Img',
        'Ext.ActionSheet'
    ],
    config: 
    {
        title: 'Camera',
        autoDestroy: false,
        navigationBar: {
            ui: 'light'
        }
    },
    initialize: function () {
        this.callParent(arguments);
        this.actions=null;
        this.actionSheet = {
            xtype: 'actionsheet',
            items: [
                                {

                                    text: 'Cancelar',                                   
                                    scope: this,
                                    handler: this.onDeleteButtonTap
                                },
                                {
                                    text: 'Enviar',
                                    ui: 'decline',
                                    scope: this,
                                    handler: this.onSaveButtonTap
                                }
                                /*
                                ,
                                {
                                    xtype: 'button',
                                    text: 'Cancelar',
                                    scope: this,
                                        //                                   
                                        //   handler: function () {
                                        //             if (this.actions)
                                        //               this.actions.hide();
                                        //   }
                                        //                                   
                                    handler: this.onBackButtonTap
                                }*/
           ]
        };
        this.tool = {
            xtype: 'imagedetails',
            title: 'Camara',
            items: [
					    {
					        ui: 'sub',
					        xtype: 'toolbar',
					        docked: 'bottom',
					        layout: {
					            type: 'hbox',
					            pack: 'center'
					        },
					        defaults: {
					            iconMask: true
					        },
					        items: [
						    {
						        ui: 'back',
						        text: '<<',
						        handler: this.onBackButtonTap,
						        scope: this
						    },
                            
                            {
                                text: 'Camara',
                                iconMask: true,
                                iconCls: 'photo1',
                                ui: 'action',
                                handler: this.onCapture,
                                scope: this
                            }

                        ]
					    }
                ]
        };
        this.add([this.tool]);
        /*
        this.on({
            scope: this,
            show: this.onShow
        });
        */

    },
    onBackButtonTap: function () {
        this.fireEvent("backButtonTapCommand", this);
    },
    onCapture: function () {
        this.fireEvent("captureCommand", this);
    },
    onSaveButtonTap: function () {
        this.fireEvent("saveButtonTapCommand", this);
    },
    onDeleteButtonTap: function () {
        this.fireEvent("deleteButtonTapCommand", this);
    },
    onShow: function () {
        this.fireEvent("show", this);
    },
    actions_view: function (val) {
        if (!this.actions)
        this.actions = Ext.Viewport.add(this.actionSheet);
        if (val) 
        {
            this.actions.show();
        }
        else 
        {
            this.actions.hide();
        }
       
    }
});
